package com.hbpa.pan.server.modules.file.converter;

import com.hbpa.pan.server.modules.file.context.CreateFolderContext;
import com.hbpa.pan.server.modules.file.context.DeleteFileContext;
import com.hbpa.pan.server.modules.file.context.UpdateFilenameContext;
import com.hbpa.pan.server.modules.file.entity.RPanUserFile;
import com.hbpa.pan.server.modules.file.po.CreateFolderPO;
import com.hbpa.pan.server.modules.file.po.DeleteFilePO;
import com.hbpa.pan.server.modules.file.po.UpdateFilenamePO;
import com.hbpa.pan.server.modules.user.context.*;
import com.hbpa.pan.server.modules.user.entity.RPanUser;
import com.hbpa.pan.server.modules.user.po.*;
import com.hbpa.pan.server.modules.user.vo.UserInfoVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * @author: BlcakTiger
 * @date: 2023/10/22 11:08
 * @contact: hsf6661@163.com
 * @description: 文件模块实体转化工具类
 */
@Mapper( componentModel = "spring")
public interface FileConverter {

    /**
     * CreateFolderPO转换成CreateFolderContext
     * @param createFolderPO 用户注册参数对象
     * @return
     */
    @Mapping(target = "parentId",expression = "java(com.hbpa.pan.core.utils.IdUtil.decrypt(createFolderPO.getParentId()))")
    @Mapping(target = "userId",expression = "java(com.hbpa.pan.server.modules.user.utils.UserIdUtil.get())")
    CreateFolderContext createFolderPO2CreateFolderContext(CreateFolderPO createFolderPO);

    /**
     * UpdateFilenamePO转换成UpdateFilenameContext
     * @param updateFilenamePO
     * @return
     */
    @Mapping(target = "fileId",expression = "java(com.hbpa.pan.core.utils.IdUtil.decrypt(updateFilenamePO.getFileId()))")
    @Mapping(target = "userId",expression = "java(com.hbpa.pan.server.modules.user.utils.UserIdUtil.get())")
    UpdateFilenameContext updateFilenamePO2UpdateFilenameContext(UpdateFilenamePO updateFilenamePO);

    /**
     * DeleteFilePO转换成DeleteFileContext
     * @param deleteFilePO
     * @return
     */
    @Mapping(target = "userId",expression = "java(com.hbpa.pan.server.modules.user.utils.UserIdUtil.get())")
    DeleteFileContext deleteFilePO2DeleteFileContext(DeleteFilePO deleteFilePO);
}
